package com.etlmaster.executor.steps.func;

import java.util.Map;

import com.etlmaster.executor.Step;
import com.etlmaster.executor.StepMeta;
import com.etlmaster.executor.annotation.StepInstruction;
import com.etlmaster.executor.steps.extract.ExtractUtil;
import com.etlmaster.executor.utils.DataCollectionUtils;
import com.etlmaster.executor.utils.StepState;

/**
 * @author Wugf
 * @date 2016-03-08
 */
@StepInstruction("distcp")
public class DistcpBetweenHdfsStep  extends Step {

	private DistcpBetweenHdfsStepMeta  meta;
	
	public DistcpBetweenHdfsStep(StepMeta meta) {
		super(meta);
		this.meta=(DistcpBetweenHdfsStepMeta) meta;
		// TODO Auto-generated constructor stub
	}

	@Override
	protected int handle() {
		
		String distcpCmd=DataCollectionUtils.getProperties("distcp_cmd");
		Map<String,Object> map=ExtractUtil.getMap(meta);
		distcpCmd=ExtractUtil.replace(distcpCmd, map);
		int code= ExtractUtil.execute(distcpCmd);
		if(code!=0){
			return StepState.RUNNING_FAILED;
		}else{
			return StepState.RUNNING_SUCCESSED;
		}
		
	}

	@Override
	public boolean stop() {
		// TODO Auto-generated method stub
		return false;
	}

}
